var req="";
function creatRequest() {
    if (window.XMLHttpRequest) {
        req = new XMLHttpRequest();
    } else if (window.ActiveXObject) {

        try {
            XMLHttpReq = new ActiveXObject("Msxm12.XMLHTTP");
        } catch (e) {
            try {
                XMLHttpReq = new ActiveXObject("Microsoft.XMLHTTP");
            } catch (e) {
            }
        }
    }
    if (!req) {
        alert("ERROR");
    }
}

function p(){
    alert("111");
}

function addTOCart(goodsId){
    alert("加入购物车成功...");
    var url="CartServlet";
    creatRequest();
    req.open("post",url,true);
    req.setRequestHeader("Content-Type","application/x-www-form-urlencoded");
    req.send("service=addToCart&goodsId="+goodsId);
}

function addGoods(goodsId){
    var url="CartServlet";
    creatRequest();
    req.open("post",url,true);
    req.setRequestHeader("Content-Type","application/x-www-form-urlencoded");
    req.send("service=addGoods&goodsId="+goodsId);
}

function deleteGoods(goodsId){
    var url="CartServlet";
    creatRequest();
    req.open("post",url,true);
    req.setRequestHeader("Content-Type","application/x-www-form-urlencoded");
    req.send("service=deleteGoods&goodsId="+goodsId);
}
